#pragma once

#include "public/build.h"
#include "core/noncopy.h"

#include "client/iclient.h"
#include "thread/thread_pool.h"

#include <map>

namespace renderit
{	
	class GModule : public core::noncopy
	{
	public:
		GModule(int argc, const char * argv[]);

	public:
		int loop();

	public:
		client::iclient * client() { return client_; }

		thread::thread_pool * thread_worker() { return thread_worker_; }
		thread::thread_pool * thread_io() { return thread_io_; }
		thread::thread_pool * thread_object() { return thread_main_; }
		thread::main_thread * thread_main() { return thread_main_; }

		const std::map<std::string, std::string>& arguments() { return arguments_; }

	public:
		const std::string& get_argument(const std::string& key)
		{
			return arguments_[key];
		}

		void add_argument(const std::string& key, const std::string& val)
		{
			arguments_[key] = val;
		}

	private:
		client::iclient * client_;
		thread::thread_pool * thread_worker_;
		thread::thread_pool * thread_io_;
	//	thread::thread_pool * thread_object_;
		thread::main_thread * thread_main_;
		std::map<std::string, std::string> arguments_;
	};

	GModule* create_G(int argc, const char * argv[]);

	extern GModule * G;
}